--------------------------------------------------------------------------------
      name:  <unnamed>
       log:  R:\Current Research\Markets-Pridemore\Work\MAR04-ModModels.log
  log type:  text
 opened on:  25 Jun 2024, 15:18:43

. 
. //  program:    Stata 
. //  task:       Sample and diagnostics 
. //  project:    Markets  
. 
. version
version 17.0

. clear all

. macro drop _all

. set linesize 80

. set more off

. local tag " 06-06-24| Cleaned 06-06-24"

. local file "MAR04-ModModels"

. local note "|`tag' | `file'"

. local opt "noparen sideway excel noaster  bdec(2)  sdec(2)  pdec(3)   adec(2) 
> e(r2) stats(coef se pval)"

. local dv "lrhom"

. local iv "fraser"

. local iv2 "infantmort" 

. local cont "edu unemp  popdense perurban  sexratio"

. 
. //      #0
. //      loading data 
. use MAR03-MedModel.dta, clear 

. 
. //      #1
. //      Moderating Model fraser X infant  
. xtreg lrhom c.`iv'##c.infant `cont', fe vce(cluster CID) 

Fixed-effects (within) regression               Number of obs     =      1,524
Group variable: CID                             Number of groups  =         88

R-squared:                                      Obs per group:
     Within  = 0.1344                                         min =          6
     Between = 0.3559                                         avg =       17.3
     Overall = 0.3452                                         max =         20

                                                F(8,87)           =      16.43
corr(u_i, Xb) = 0.2210                          Prob > F          =     0.0000

                                   (Std. err. adjusted for 88 clusters in CID)
------------------------------------------------------------------------------
             |               Robust
       lrhom | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
      fraser |  -.4020138   .1624428    -2.47   0.015    -.7248865   -.0791411
  infantmort |  -.0796355   .0786201    -1.01   0.314    -.2359014    .0766303
             |
    c.fraser#|
c.infantmort |   .0124292   .0119085     1.04   0.300    -.0112403    .0360987
             |
         edu |  -2.543008   .8270247    -3.07   0.003    -4.186809   -.8992064
       unemp |   .0017229   .0080646     0.21   0.831    -.0143065    .0177522
    popdense |   -.000341   .0001026    -3.32   0.001     -.000545   -.0001371
    perurban |      .0086   .0208776     0.41   0.681    -.0328966    .0500965
    sexratio |   -.012276   .0070502    -1.74   0.085    -.0262891     .001737
       _cons |   6.328022   1.620262     3.91   0.000     3.107575    9.548469
-------------+----------------------------------------------------------------
     sigma_u |  1.1287163
     sigma_e |  .40937117
         rho |  .88374967   (fraction of variance due to u_i)
------------------------------------------------------------------------------

. outreg2 using `file', replace `opt'  ctitle(Fraser X infant)
MAR04-ModModels.xml
dir : seeout

. //      #2
. //      Moderating hertiage X infant 
. xtreg lrhom c.heritage##c.infant `cont', fe vce(cluster CID) 

Fixed-effects (within) regression               Number of obs     =      1,487
Group variable: CID                             Number of groups  =         87

R-squared:                                      Obs per group:
     Within  = 0.1230                                         min =          3
     Between = 0.3187                                         avg =       17.1
     Overall = 0.3065                                         max =         20

                                                F(8,86)           =      19.71
corr(u_i, Xb) = 0.1590                          Prob > F          =     0.0000

                                   (Std. err. adjusted for 87 clusters in CID)
------------------------------------------------------------------------------
             |               Robust
       lrhom | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
    heritage |   -.026852   .0137692    -1.95   0.054    -.0542243    .0005203
  infantmort |   -.017787    .061802    -0.29   0.774    -.1406453    .1050714
             |
  c.heritage#|
c.infantmort |   .0004378    .001017     0.43   0.668    -.0015839    .0024596
             |
         edu |  -2.492782   .8373561    -2.98   0.004    -4.157391   -.8281737
       unemp |   .0020291   .0084113     0.24   0.810    -.0146921    .0187502
    popdense |  -.0003772   .0000986    -3.82   0.000    -.0005732   -.0001811
    perurban |   .0073162   .0218941     0.33   0.739    -.0362079    .0508403
    sexratio |  -.0106301   .0067444    -1.58   0.119    -.0240376    .0027774
       _cons |   5.040055    1.52997     3.29   0.001     1.998576    8.081535
-------------+----------------------------------------------------------------
     sigma_u |  1.1528968
     sigma_e |  .41310286
         rho |   .8862174   (fraction of variance due to u_i)
------------------------------------------------------------------------------

. outreg2 using `file', append `opt' ctitle(hertiage X infant)
MAR04-ModModels.xml
dir : seeout

. //      #3
. //      Moderating ROL X infant 
. xtreg lrhom c.rol##c.infant `cont', fe vce(cluster CID) 

Fixed-effects (within) regression               Number of obs     =      1,379
Group variable: CID                             Number of groups  =         88

R-squared:                                      Obs per group:
     Within  = 0.1171                                         min =          5
     Between = 0.3594                                         avg =       15.7
     Overall = 0.3869                                         max =         18

                                                F(8,87)           =      10.38
corr(u_i, Xb) = 0.0475                          Prob > F          =     0.0000

                                   (Std. err. adjusted for 88 clusters in CID)
------------------------------------------------------------------------------
             |               Robust
       lrhom | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
         rol |  -.5371651   .2081603    -2.58   0.012    -.9509062    -.123424
  infantmort |   .0108901   .0191776     0.57   0.572    -.0272275    .0490077
             |
       c.rol#|
c.infantmort |   .0052004   .0149933     0.35   0.730    -.0246003    .0350011
             |
         edu |  -3.147877   .8964283    -3.51   0.001    -4.929625   -1.366128
       unemp |   .0023565   .0069403     0.34   0.735    -.0114381    .0161511
    popdense |  -.0002267   .0001208    -1.88   0.064    -.0004668    .0000133
    perurban |   .0078914   .0248773     0.32   0.752    -.0415548    .0573377
    sexratio |   -.004345   .0083738    -0.52   0.605    -.0209888    .0122987
       _cons |   3.300004   1.745791     1.89   0.062    -.1699455    6.769954
-------------+----------------------------------------------------------------
     sigma_u |  1.1127573
     sigma_e |  .40697221
         rho |  .88202032   (fraction of variance due to u_i)
------------------------------------------------------------------------------

. outreg2 using `file', append `opt' ctitle(rol X infant)
MAR04-ModModels.xml
dir : seeout

. 
. //      #4
. //      GDP set up 
. * qladder gdp 
. gen lgdp=log(gdp)
(17 missing values generated)

. label var lgdp "Ln GDP per capita"

. 
. //      #5
. //      Moderating GDP 
. xtreg `dv' c.fraser##c.lgdp `iv2' `cont', fe vce(cluster CID)

Fixed-effects (within) regression               Number of obs     =      1,507
Group variable: CID                             Number of groups  =         87

R-squared:                                      Obs per group:
     Within  = 0.1595                                         min =          6
     Between = 0.2789                                         avg =       17.3
     Overall = 0.2798                                         max =         20

                                                F(9,86)           =      21.00
corr(u_i, Xb) = -0.2075                         Prob > F          =     0.0000

                                   (Std. err. adjusted for 87 clusters in CID)
------------------------------------------------------------------------------
             |               Robust
       lrhom | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
      fraser |  -1.687684   .6993717    -2.41   0.018    -3.077988   -.2973786
        lgdp |  -2.049407   .6166664    -3.32   0.001      -3.2753   -.8235152
             |
    c.fraser#|
      c.lgdp |   .1694942   .0735323     2.31   0.024     .0233168    .3156717
             |
  infantmort |  -.0129424   .0141918    -0.91   0.364    -.0411547      .01527
         edu |  -1.642303   1.159215    -1.42   0.160    -3.946746    .6621403
       unemp |  -.0086718   .0097325    -0.89   0.375    -.0280193    .0106756
    popdense |  -.0003182   .0001257    -2.53   0.013    -.0005681   -.0000682
    perurban |   .0146533   .0240748     0.61   0.544    -.0332058    .0625124
    sexratio |  -.0181164   .0079225    -2.29   0.025    -.0338658    -.002367
       _cons |   23.09045    6.39643     3.61   0.001     10.37477    35.80613
-------------+----------------------------------------------------------------
     sigma_u |  1.1941626
     sigma_e |  .40558952
         rho |  .89657338   (fraction of variance due to u_i)
------------------------------------------------------------------------------

. outreg2 using `file', append `opt' ctitle(faser X lgdp)
MAR04-ModModels.xml
dir : seeout

. 
. xtreg `dv' c.heritage##c.lgdp `iv2' `cont', fe vce(cluster CID)

Fixed-effects (within) regression               Number of obs     =      1,470
Group variable: CID                             Number of groups  =         86

R-squared:                                      Obs per group:
     Within  = 0.1468                                         min =          3
     Between = 0.3055                                         avg =       17.1
     Overall = 0.3011                                         max =         20

                                                F(9,85)           =      21.18
corr(u_i, Xb) = -0.2954                         Prob > F          =     0.0000

                                   (Std. err. adjusted for 86 clusters in CID)
------------------------------------------------------------------------------
             |               Robust
       lrhom | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
    heritage |   .0130896   .0467794     0.28   0.780    -.0799204    .1060997
        lgdp |  -.7247838   .4829165    -1.50   0.137    -1.684951    .2353836
             |
  c.heritage#|
      c.lgdp |  -.0027206   .0050377    -0.54   0.591    -.0127369    .0072957
             |
  infantmort |  -.0071639   .0150382    -0.48   0.635    -.0370639    .0227361
         edu |  -1.386994   1.176374    -1.18   0.242    -3.725941    .9519527
       unemp |  -.0128969    .010618    -1.21   0.228    -.0340084    .0082146
    popdense |  -.0002414   .0001172    -2.06   0.043    -.0004745   -8.33e-06
    perurban |   .0123178   .0233993     0.53   0.600    -.0342064    .0588419
    sexratio |  -.0178205   .0077899    -2.29   0.025     -.033309    -.002332
       _cons |   10.79174   5.153178     2.09   0.039     .5458392    21.03764
-------------+----------------------------------------------------------------
     sigma_u |  1.2041691
     sigma_e |   .4097285
         rho |  .89623748   (fraction of variance due to u_i)
------------------------------------------------------------------------------

. outreg2 using `file', append `opt' ctitle(heritage X lgdp)
MAR04-ModModels.xml
dir : seeout

. 
. xtreg `dv' c.rol##c.lgdp `iv2' `cont', fe vce(cluster CID)

Fixed-effects (within) regression               Number of obs     =      1,364
Group variable: CID                             Number of groups  =         87

R-squared:                                      Obs per group:
     Within  = 0.1315                                         min =          5
     Between = 0.3301                                         avg =       15.7
     Overall = 0.3445                                         max =         18

                                                F(9,86)           =      12.94
corr(u_i, Xb) = -0.3256                         Prob > F          =     0.0000

                                   (Std. err. adjusted for 87 clusters in CID)
------------------------------------------------------------------------------
             |               Robust
       lrhom | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
         rol |    .511469   1.456142     0.35   0.726    -2.383246    3.406184
        lgdp |  -.6566659   .3985312    -1.65   0.103     -1.44892    .1355879
             |
c.rol#c.lgdp |  -.0948384   .1516941    -0.63   0.533    -.3963963    .2067196
             |
  infantmort |   .0002472   .0177331     0.01   0.989     -.035005    .0354995
         edu |  -2.170547   1.192368    -1.82   0.072    -4.540897    .1998028
       unemp |  -.0088853   .0098406    -0.90   0.369    -.0284477     .010677
    popdense |  -.0001131   .0001556    -0.73   0.469    -.0004224    .0001961
    perurban |   .0128032   .0252935     0.51   0.614    -.0374786    .0630851
    sexratio |   -.009932   .0094293    -1.05   0.295    -.0286767    .0088128
       _cons |   9.176766   4.473722     2.05   0.043     .2833011    18.07023
-------------+----------------------------------------------------------------
     sigma_u |  1.1902892
     sigma_e |  .40583428
         rho |  .89585677   (fraction of variance due to u_i)
------------------------------------------------------------------------------

. outreg2 using `file', append `opt' ctitle(rol X lgdp)
MAR04-ModModels.xml
dir : seeout

. 
. //      #6
. //      INfant and GDP mods together
. xtreg `dv' c.fraser##c.lgdp c.fraser##c.`iv2' `cont', fe vce(cluster CID)
note: fraser omitted because of collinearity.

Fixed-effects (within) regression               Number of obs     =      1,507
Group variable: CID                             Number of groups  =         87

R-squared:                                      Obs per group:
     Within  = 0.1809                                         min =          6
     Between = 0.2773                                         avg =       17.3
     Overall = 0.2812                                         max =         20

                                                F(10,86)          =      20.33
corr(u_i, Xb) = -0.1436                         Prob > F          =     0.0000

                                   (Std. err. adjusted for 87 clusters in CID)
------------------------------------------------------------------------------
             |               Robust
       lrhom | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
      fraser |  -4.027198   1.135337    -3.55   0.001    -6.284173   -1.770223
        lgdp |  -3.345676   .7350785    -4.55   0.000    -4.806964   -1.884389
             |
    c.fraser#|
      c.lgdp |   .3779155   .1081273     3.50   0.001     .1629656    .5928654
             |
      fraser |          0  (omitted)
  infantmort |  -.2513516   .1085426    -2.32   0.023    -.4671273    -.035576
             |
    c.fraser#|
c.infantmort |   .0348964   .0163778     2.13   0.036     .0023384    .0674544
             |
         edu |  -1.601994   1.109652    -1.44   0.152    -3.807909    .6039204
       unemp |  -.0086621   .0095003    -0.91   0.364    -.0275479    .0102238
    popdense |  -.0004381   .0001217    -3.60   0.001    -.0006799   -.0001962
    perurban |   .0130069   .0192879     0.67   0.502    -.0253363      .05135
    sexratio |  -.0161678   .0077678    -2.08   0.040    -.0316096   -.0007259
       _cons |   37.78911   7.189683     5.26   0.000     23.49649    52.08172
-------------+----------------------------------------------------------------
     sigma_u |  1.1738731
     sigma_e |  .40054024
         rho |  .89571544   (fraction of variance due to u_i)
------------------------------------------------------------------------------

. outreg2 using `file', append `opt' ctitle(fraser X lgdp fraserX`iv2')
MAR04-ModModels.xml
dir : seeout

. qui reg `dv' c.fraser##c.lgdp c.fraser##c.`iv2' `cont', vce(cluster CID)

. vif

    Variable |       VIF       1/VIF  
-------------+----------------------
      fraser |    192.73    0.005189
        lgdp |    200.72    0.004982
    c.fraser#|
      c.lgdp |    575.82    0.001737
  infantmort |    345.29    0.002896
    c.fraser#|
c.infantmort |    326.07    0.003067
         edu |      3.22    0.310971
       unemp |      1.18    0.845965
    popdense |      1.26    0.792801
    perurban |      1.85    0.539603
    sexratio |      1.27    0.787857
-------------+----------------------
    Mean VIF |    164.94

. 
. xtreg `dv' c.heritage##c.lgdp c.heritage##c.`iv2' `cont', fe vce(cluster CID)
note: heritage omitted because of collinearity.

Fixed-effects (within) regression               Number of obs     =      1,470
Group variable: CID                             Number of groups  =         86

R-squared:                                      Obs per group:
     Within  = 0.1473                                         min =          3
     Between = 0.3070                                         avg =       17.1
     Overall = 0.3033                                         max =         20

                                                F(10,85)          =      18.22
corr(u_i, Xb) = -0.2891                         Prob > F          =     0.0000

                                   (Std. err. adjusted for 86 clusters in CID)
------------------------------------------------------------------------------
             |               Robust
       lrhom | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
    heritage |  -.0192212   .0972748    -0.20   0.844    -.2126295    .1741871
        lgdp |  -.9070644   .6365104    -1.43   0.158    -2.172618    .3584888
             |
  c.heritage#|
      c.lgdp |   .0001517   .0088697     0.02   0.986    -.0174837    .0177871
             |
    heritage |          0  (omitted)
  infantmort |  -.0382978   .0949437    -0.40   0.688    -.2270714    .1504758
             |
  c.heritage#|
c.infantmort |   .0004996   .0015144     0.33   0.742    -.0025114    .0035107
             |
         edu |  -1.376558   1.171272    -1.18   0.243     -3.70536    .9522438
       unemp |  -.0136598   .0103457    -1.32   0.190    -.0342298    .0069102
    popdense |  -.0002547   .0001205    -2.11   0.037    -.0004943   -.0000151
    perurban |   .0130318   .0237086     0.55   0.584    -.0341072    .0601708
    sexratio |   -.017621    .007783    -2.26   0.026    -.0330956   -.0021464
       _cons |   12.76724   6.692792     1.91   0.060    -.5398221     26.0743
-------------+----------------------------------------------------------------
     sigma_u |   1.199839
     sigma_e |  .40976742
         rho |  .89554778   (fraction of variance due to u_i)
------------------------------------------------------------------------------

. outreg2 using `file', append `opt' ctitle(heritage X lgdp heritage`iv2')
MAR04-ModModels.xml
dir : seeout

. 
. qui reg `dv' c.heritage##c.lgdp c.heritage##c.`iv2' `cont', vce(cluster CID)

. vif 

    Variable |       VIF       1/VIF  
-------------+----------------------
    heritage |    203.85    0.004905
        lgdp |    124.06    0.008061
  c.heritage#|
      c.lgdp |    477.59    0.002094
  infantmort |    201.03    0.004974
  c.heritage#|
c.infantmort |    185.98    0.005377
         edu |      3.36    0.297799
       unemp |      1.27    0.788459
    popdense |      1.35    0.740264
    perurban |      1.79    0.559166
    sexratio |      1.25    0.803111
-------------+----------------------
    Mean VIF |    120.15

. 
. xtreg `dv' c.rol##c.lgdp c.rol##c.`iv2' `cont', fe vce(cluster CID)
note: rol omitted because of collinearity.

Fixed-effects (within) regression               Number of obs     =      1,364
Group variable: CID                             Number of groups  =         87

R-squared:                                      Obs per group:
     Within  = 0.1318                                         min =          5
     Between = 0.3274                                         avg =       15.7
     Overall = 0.3414                                         max =         18

                                                F(10,86)          =      12.35
corr(u_i, Xb) = -0.3282                         Prob > F          =     0.0000

                                   (Std. err. adjusted for 87 clusters in CID)
------------------------------------------------------------------------------
             |               Robust
       lrhom | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
         rol |   .8803278   1.807146     0.49   0.627    -2.712159    4.472814
        lgdp |  -.6604029   .4019081    -1.64   0.104     -1.45937    .1385638
             |
c.rol#c.lgdp |  -.1280075   .1784763    -0.72   0.475    -.4828067    .2267917
             |
         rol |          0  (omitted)
  infantmort |  -.0014714   .0199264    -0.07   0.941    -.0410838    .0381409
             |
       c.rol#|
c.infantmort |  -.0052027   .0181484    -0.29   0.775    -.0412806    .0308752
             |
         edu |  -2.200883   1.180301    -1.86   0.066    -4.547245    .1454788
       unemp |  -.0090647   .0100073    -0.91   0.368    -.0289586    .0108293
    popdense |  -.0000998   .0001651    -0.60   0.547    -.0004281    .0002285
    perurban |   .0128447   .0253797     0.51   0.614    -.0376084    .0632979
    sexratio |  -.0101223    .009457    -1.07   0.287    -.0289221    .0086775
       _cons |   9.266626   4.564941     2.03   0.045     .1918232    18.34143
-------------+----------------------------------------------------------------
     sigma_u |  1.1938364
     sigma_e |  .40592898
         rho |  .89636737   (fraction of variance due to u_i)
------------------------------------------------------------------------------

. outreg2 using `file', append `opt' title(rol X lgdp rol`iv2')
MAR04-ModModels.xml
dir : seeout

. qui reg `dv' c.rol##c.lgdp c.rol##c.`iv2' `cont', vce(cluster CID)

. vif 

    Variable |       VIF       1/VIF  
-------------+----------------------
         rol |    300.25    0.003331
        lgdp |      6.72    0.148717
c.rol#c.lgdp |    255.95    0.003907
  infantmort |      3.11    0.321146
       c.rol#|
c.infantmort |      6.84    0.146301
         edu |      3.23    0.309233
       unemp |      1.24    0.809228
    popdense |      1.11    0.900413
    perurban |      1.90    0.527365
    sexratio |      1.28    0.781713
-------------+----------------------
    Mean VIF |     58.16

. 
. //      #7
. //      save and close
. note:  Moderating models | `note'.

. notes

_dta:
  1.  Cleaned WHO homicide data for overall, age and gender | merged data
      together | |meg | 03-23-2023 | CT01-DataMerge-V02.
  2.  30JUN2022
  3.  Got data out of .csv into .dta, merged data, and generated variables | \
      06-28-2022 \ SP01-CleaningData.
  4.  Completed sample and pre-model diagnostics | | 07-05-23| Cleaned 06-06-24
      | MAR02-SampDiag.
  5.  Hertiage heritage -> infant unable to find maximum | | 07-05-23| Cleaned
      06-06-24 | MAR03-MedModel.
  6.  Mediation models | | 07-05-23| Cleaned 06-06-24 | MAR03-MedModel.
  7.  Moderating models | | 06-06-24| Cleaned 06-06-24 | MAR04-ModModels.

ryoung:
  1.  (pop1519*1000)+(pop2024*1000)/pop *100

rmyoung:
  1.  (mpop1519*1000)+(mpop2024*1000)+(mpop2529*1000)/popmale*100 | \ 06-28-2022
      \ SP01-CleaningData.

edu:
  1.  (eys_index+mys_index)/2 | \ 06-28-2022 \ SP01-CleaningData.

unemp:
  1.  Nation Estimates then missing filled with ILO estimates corr 1 or .9457 |
      \ 06-28-2022 \ SP01-CleaningData.

sexratio:
  1.  popmale/popfemale*100 | \ 06-28-2022 \ SP01-CleaningData.

eys_index:
  1.  (eys-0)/(18+0) | \ 06-28-2022 \ SP01-CleaningData

mys_index:
  1.  (mys-0)/(15+0) | \ 06-28-2022 \ SP01-CleaningData

lrhom:
  1.  | 07-05-23| Cleaned 06-06-24 | MAR02-SampDiag.

. save `file'.dta, replace 
file MAR04-ModModels.dta saved

. log close 
      name:  <unnamed>
       log:  R:\Current Research\Markets-Pridemore\Work\MAR04-ModModels.log
  log type:  text
 closed on:  25 Jun 2024, 15:19:05
--------------------------------------------------------------------------------
